<?php
$this->breadcrumbs=array(
	'Carga Semestral'=>array('admin'),
	'Criar',
);

Yii::app()->clientScript->registerCssFile(Yii::app()->baseUrl.'/assets/884ba3ad/gridview/styles.css');
Yii::app()->clientScript->registerCss('id', '.row{margin-top:10px;}.hidden{display:none;}');
Yii::app()->clientScript->registerScript('submit','
    function submitVoltar(){
        $("#template-form").attr("action", "voltar");
        $("#submitBtn").click();
    }
    function submitFinalize(){
        $("#template-form").attr("action", "finalize");
        $("#submitBtn").click();
    }
', CClientScript::POS_HEAD
);
?>
<?php echo $this->renderPartial('../layouts/mensagemErro', array('model' => $model)); ?>
<h1>Criar Carga Semestral</h1>
<div class="form">
 <?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'template-form',
    'enableAjaxValidation'=>false,
)); ?>
    <div class="row sameLine">
        <?php echo $form->labelEx($model,'NU_ANO'); ?>
        <?php echo $form->textField($model,'NU_ANO', array('size'=>10,'maxlength'=>4)); ?>
    </div>
    <div class="row sameLine">
        <?php echo $form->labelEx($model,'NU_SEMESTRE'); ?>
        <?php echo $form->textField($model,'NU_SEMESTRE', array('size'=>10,'maxlength'=>1)); ?>
    </div>
    <div class="row sameLine">
        <?php echo $form->labelEx($model,'DT_INI'); ?>
        <?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                $this->widget('CJuiDateTimePicker',array(
                    'model'=>$model, //Model object
                    'attribute'=>'DT_INI', //attribute name
                    'mode'=>'date', //use "time","date" or "datetime" (default)
                    'options'=>array(
                        'minDate'=> '0',
                        'dateFormat'=>'dd/mm/yy'
                    ),
                    'htmlOptions'=>array(
                        'size'=>8
                    )
                ));
            ?>
    </div>
    <div class="row sameLine">
        <?php echo $form->labelEx($model,'DT_FIM'); ?>
        <?php Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
                $this->widget('CJuiDateTimePicker',array(
                    'model'=>$model, //Model object
                    'attribute'=>'DT_FIM', //attribute name
                    'mode'=>'date', //use "time","date" or "datetime" (default)
                    'options'=>array(
                        'minDate'=> '0',
                        'dateFormat'=>'dd/mm/yy'
                    ),
                    'htmlOptions'=>array(
                        'size'=>8
                    )
                ));
            ?>
    </div>
    <div class="row sameLine">
        <?php echo $form->labelEx($model,'TX_NOME'); ?>
        <?php echo $form->textField($model,'TX_NOME',array('size'=>50,'maxlength'=>50)); ?>
    </div>
    <div class="grid-view" id="template-grid">
        <table id="tblCarga" class="items">
            <thead>
                <tr>
                    <th id="template-grid_hidden" class="hidden"></th>
                    <th id="template-grid_c0">Disciplina</th>
                    <th id="template-grid_c1">Turma</th>
                    <th id="template-grid_c2">Dias</th>
                    <th id="template-grid_c3">Hora Inicial</th>
                    <th id="template-grid_c4">Hora Final</th>
                    <th id="template-grid_c5">Finalidade</th>
                    <th id="template-grid_c6">Capacidade</th>
                    <th id="template-grid_c7">Professor</th>
                    <th id="template-grid_c8">Ambiente</th>
                </tr>
            </thead>
            <tbody>
                <?php
                    $count = 0;
                    $ct = 0;
                    foreach ($modelCS as $value) {
                        $ct++;
                        echo '<tr id="'.$value->getId().'" class="'.($count%2==0?'even':'odd') .'">'.
                            '<td class="hidden">'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][disciplina]" value="'.$value->disciplina.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][turma]" value="'.$value->turma.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][diasSemana]" value="'.$value->diasSemana.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][finalidade]" value="'.$value->finalidade.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][finalidadeText]" value="'.$value->finalidadeText.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][recursos]" value="'.$value->recursos.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][horaIni]" value="'.$value->horaIni.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][horaFim]" value="'.$value->horaFim.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][capacidade]" value="'.$value->capacidade.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][professor]" value="'.$value->professor.'" />'.
                            '<input type="hidden" name="CargaSemestral['.$ct.'][ambienteSelecionado]" value="'.$value->ambienteSelecionado->ID_AMBIENTE.'" />'.
                            '</td>'.
                            '<td>'.$value->disciplina.'</td>'.
                            '<td class="turma">'.$value->turma.'</td>'.
                            '<td>'.$value->diasSemana.'</td>'.
                            '<td>'.MethodUtils::getTimeFromInt($value->horaIni).'</td>'.
                            '<td>'.MethodUtils::getTimeFromInt($value->horaFim).'</td>'.
                            '<td>'.$value->finalidadeText.'</td>'.
                            '<td>'.$value->capacidade.'</td>'.
                            '<td>'.$value->professor.'</td>'.
                            '<td>'.($value->ambienteSelecionado != null ? $value->ambienteSelecionado->iD_PREDIO->TX_DESCRICAO. ' - '. $value->ambienteSelecionado->TX_NOME : '').'</td>'.
                            '</tr>';
                        $count++;
                    }
                ?>
            </tbody>
        </table>
        <input id="counter" type="hidden" value="<?php echo $ct ?>" />
    </div>
    <div class="row buttons">
        <div class="row">
            <?php echo CHtml::submitButton('Voltar', array('id'=>'submitBtn1')); ?>
            <?php echo CHtml::submitButton('Finalizar', array('id'=>'submitBtn2')); ?>
        </div>
    </div>
</div><!-- form -->
<?php $this->endWidget(); ?>
